









<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>sli4j - Extend sli4j</title>
    <link rel="stylesheet" href="./css/maven-theme.css" type="text/css" />
    <link rel="stylesheet" href="./css/maven-base.css" type="text/css"/>
    <link rel="stylesheet" href="./css/prettify.css" type="text/css"/>
    <link rel="stylesheet" href="./css/print.css" type="text/css" media="print" />
    <script type="text/javascript" src="./js/prettify.js"></script>
    <script type="text/javascript" src="./js/niftycube.js"></script>
    <script type="text/javascript">
        window.onload=function() {
            Nifty("div\#wrapper", "big");
            Nifty("div#breadcrumbs", "small");
            Nifty("div\#navcolumn", "small");
            Nifty("div.source", "medium");
            prettyPrint();
        }
    </script>
          <meta name="author" content="Simone Tripodi" />
          </head>
  <body>
    <div id="wrapper">
        <div id="banner">
                      <a href="http://sli4j.googlecode.com/svn/site/1.0/index.html" id="bannerLeft"  >
    
                                            <img src="images/logo.png" alt="Simple Logging Injector for Java" />
    
            </a>
                            <div class="clear">
            <hr/>
          </div>
        </div>
        <div id="breadcrumbs">
              
  

  
    
            
  
    
            <div class="xleft">
        <span id="publishDate">Last Published: 2010-02-12</span>
                  &nbsp;| <span id="projectVersion">Version: 1.0</span>
                      </div>
                <div class="xright">      
  

  
    
            
  
    
  </div>
          <div class="clear">
            <hr/>
          </div>
        </div>
        <div id="leftColumn">
          <div id="navcolumn">
               
  

  
    
            
  
    
                       <h5>sli4j</h5>
            <ul>
              
    <li class="none">
                    <a href="index.html">Home</a>
          </li>
              
    <li class="none">
                    <a href="juli.html">JULI</a>
          </li>
              
    <li class="none">
                    <a href="acl.html">Apache Commons Logging</a>
          </li>
              
    <li class="none">
                    <a href="log4j.html">Apache log4j</a>
          </li>
              
    <li class="none">
                    <a href="slf4j.html">Simple Logging Facade for Java</a>
          </li>
              
    <li class="none">
              <strong>Extend sli4j</strong>
        </li>
          </ul>
              <h5>Miscellaneous</h5>
            <ul>
              
    <li class="none">
                    <a href="stats.html">Project stats</a>
          </li>
              
    <li class="none">
                    <a href="sli4j-1.0.pdf">PDF Manual</a>
          </li>
          </ul>
              <h5>Project Documentation</h5>
            <ul>
              
                
                    
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
                  
              
        <li class="collapsed">
                    <a href="project-info.html">Project Information</a>
                </li>
              
                
                    
                  
                  
                  
              
        <li class="collapsed">
                    <a href="project-reports.html">Project Reports</a>
                </li>
          </ul>
              <h5>Modules</h5>
            <ul>
              
    <li class="none">
                    <a href="sli4j-core/index.html">Core</a>
          </li>
              
    <li class="none">
                    <a href="sli4j-testfw/index.html">slf4j Test framework</a>
          </li>
              
    <li class="none">
                    <a href="sli4j-juli/index.html">JULI</a>
          </li>
              
    <li class="none">
                    <a href="sli4j-acl/index.html">Apache Commons Logging</a>
          </li>
              
    <li class="none">
                    <a href="sli4j-log4j/index.html">Apache Log4j</a>
          </li>
              
    <li class="none">
                    <a href="sli4j-slf4j/index.html">slf4j-slf4j</a>
          </li>
              
    <li class="none">
                    <a href="sli4j-slf4j-nop/index.html">slf4j-nop</a>
          </li>
              
    <li class="none">
                    <a href="sli4j-slf4j-simple/index.html">slf4j-simple</a>
          </li>
              
    <li class="none">
                    <a href="sli4j-slf4j-jcl/index.html">slf4j-jcl</a>
          </li>
              
    <li class="none">
                    <a href="sli4j-slf4j-jdk14/index.html">slf4j-jdk14</a>
          </li>
              
    <li class="none">
                    <a href="sli4j-slf4j-log4j/index.html">slf4j-log4j</a>
          </li>
              
    <li class="none">
                    <a href="sli4j-slf4j-logback/index.html">slf4j-logback</a>
          </li>
          </ul>
              <h5>External Links</h5>
            <ul>
              
    <li class="none">
                    <a href="../ibaguice/">Project Page</a>
          </li>
              
    <li class="none">
                    <a href="../google-guice/">Google Guice</a>
          </li>
          </ul>
                                               <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
            <img class="poweredBy"
                 alt="Built by Maven"
                 src="./images/logos/maven-feather.png"
                 width="90"
                 height="30"
                 border="1" />
          </a>
                           
  

  
    
            
  
    
            </div>
        </div>
        <div id="bodyColumn">
          <div id="contentBox">
            <div class="section"><h2>Extend sli4j</h2>
<p>Exigent users that have the need to integrate not already supported logging framework, can easily do it by following the listed steps:</p>
<ol type="1"><li>add the <tt>core</tt> dependency in the <tt>pom.xml</tt>:<div class="source"><pre>&lt;dependency&gt;
    &lt;groupId&gt;com.google.code.sli4j&lt;/groupId&gt;
    &lt;artifactId&gt;sli4j-core&lt;/artifactId&gt;
    &lt;version&gt;XX.XX&lt;/version&gt;
    &lt;scope&gt;compile&lt;/scope&gt;
&lt;/dependency&gt;</pre>
</div>
</li>
<li>Extend the <tt>com.google.code.sli4j.core.AbstractLoggerInjector</tt>, that's the class responsibile of creating and injecting the desired Logger, specifying the Logger type:<div class="source"><pre>import java.lang.reflect.Field;

import com.acme.MyLogger;
import com.acme.MyLoggerFactory;

import com.google.code.sli4j.core.AbstractLoggerInjector;

public final class AcmeLoggerInjector extends AbstractLoggerInjector&lt;MyLogger&gt; {

    public AcmeLoggerInjector(Field field) {
        super(field);
    }

    @Override
    protected MyLogger createLogger(Class&lt;?&gt; klass) {
        return MyLoggerFactory.getLog(klass);
    }

}</pre>
</div>
</li>
<li>Extend the <tt>com.google.code.sli4j.core.AbstractLoggingModule</tt>, specifying the Logger type and the <tt>com.google.code.sli4j.core.AbstractLoggerInjector</tt> type:<div class="source"><pre>import com.acme.MyLogger;

import com.google.code.sli4j.core.AbstractLoggingModule;
import com.google.inject.TypeLiteral;
import com.google.inject.matcher.Matcher;

public final class AcmeLoggingModule extends AbstractLoggingModule&lt;MyLogger&gt; {

    public ACLLoggingModule(Matcher&lt;? super TypeLiteral&lt;?&gt;&gt; matcher) {
        super(matcher, AcmeLoggerInjector.class);
    }

}</pre>
</div>
</li>
<li>Plug your new logging module and enjoy ;)</li>
</ol>
</div>

          </div>
        </div>
        <div class="clear">
          <hr/>
        </div>
        <div id="footer">
          <div class="xright">Copyright &#169;         
   
          2010.
    
      All Rights Reserved.    
  

  
    
            
  
    
  </div>
          <div class="clear">
            <hr/>
          </div>
        </div>
    </div>
  </body>
</html>
